<? include("acceso.php");?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Admin</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">
		<link href="css/bootstrap.css" rel="stylesheet">
		<link href="css/bootstrap-responsive.css" rel="stylesheet">
		<link href="css/adm.css" rel="stylesheet">
		<!--[if lt IE 9]><script type="text/javascript" src="js/html5.js"></script><![endif]-->
		<!--<script src="js/bootstrap.js"></script>-->
<script language=javascript>
function ventanaSecundaria (URL){
   window.open(URL,"ventana1","width=710,height=790,scrollbars=yes")
}
function ventanaSecundaria2 (URL){
   window.open(URL,"ventana2","width=570,height=430,scrollbars=yes")
}

function ventanaSecundaria3 (URL){
   window.open(URL,"ventana3","width=1260,height=920,scrollbars=yes")
}
</script>
    
   
  
<script language="JavaScript">

function getHTTPObject() {

	var xmlhttp;

	if (window.XMLHttpRequest) {

		xmlhttp = new XMLHttpRequest();

	}

	else if (window.ActiveXObject) {

		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

	}

	return xmlhttp;

}



function nuevoAjax(){

	var xmlhttp=false;

 	try {

 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

 	} catch (e) {

 		try {

 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

 		} catch (E) {

 			xmlhttp = false;

 		}

  	}



	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

 		xmlhttp = new XMLHttpRequest();

	}

	return xmlhttp;

}




function deleteRow(key)

{

	if(!confirm(" Desea eliminar el post .")) 

		{return false;} 

	 else {	

		ajax = nuevoAjax();

		ajax.open("GET","delet_tem.php?codT="+key,true);

		var detalles = document.getElementById("result");

		ajax.onreadystatechange=function() {

			if(ajax.readyState==4){

				window.location.reload();
				
				 detalles.innerHTML = conexion1.responseText;

			}

		}

		

		ajax.send(null);

	 }

	

}


function validar(key,key2)

{

	if(!confirm(" Desea cambiar de estado.")) 

		{return false;} 

	 else {	

		ajax = nuevoAjax();

		ajax.open("GET","serv_valid.php?codT="+key+"&codC="+key2,true);

		

		ajax.onreadystatechange=function() {

			if(ajax.readyState==4){

				window.location.reload();

			}

		}

		

		ajax.send(null);

	 }

	

}












</script>
   
    
</head>



<body  >
<?php 
if($loginCorrecto) 
{ ?>
<div id="navbar" class="navbar navbar-fixed-top">
	<div class="navbar-inner">
		<a class="brand" href="inicio.php"><img src="../img/logo_02.png" alt="Jóvenes Hoy"></a>
		<ul class="nav">
			<li><a href="inicio.php">inicio</a></li>
			<li ><a href="list_titulos.php">tus dudas y preguntas</a></li>
            <li ><a href="list_mus.php">música</a></li>
             <li><a href="list_vid.php">vídeo</a></li>
            <li  ><a href="list_not.php">noticias</a></li>
            <li class="active"><a href="list_web.php">webquest</a></li>
			<li><a href="list_recurs2.php">recursos</a></li>
            <li><a href="list_libro.php">otros libros</a></li>
			<li><a href="listImg.php">imágenes home</a></li>
		</ul>
	</div>
</div>
<div class="container-fluid">
	<div align="right" style="margin-top:100px" ><? echo $idnombre;?>&nbsp;&nbsp;&nbsp;&nbsp;<a href="logout.php">Salir</a></div>
 <!-------- ini-->


<?

$registros = 150;

if (!$pagina) { 
    $inicio = 0; 
    $pagina = 1; 
} 
else { 
    $inicio = ($pagina - 1) * $registros; 
} 


 

//include'clsJovAdm.php';
$objContenido =  new contenido;
$objContenido -> cnox();
$sqltemas = $objContenido -> temas();


$ord=$_GET["ord"];

if (!$ord) { 
    $ord = "id_concep"; 
	$ord2 = "desc"; 
   
} 
else { 
    $ord = $ord; 
	if($ord=="post_date")
	 {
	$ord2 = "desc"; 
	 }
	 else
	 {$ord2 = "asc"; 
		 }
} 




$resultados = mysql_query("select relac.id_tema as id_tema,conc.id_concep as id_concep,conc.titulo as titulo,conc.post_date as post_date,conc.validar as validar from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='6' order by $ord $ord2");
	$total_registros = mysql_num_rows($resultados); 
$resultados = mysql_query("select relac.id_tema as id_tema,conc.id_concep as id_concep,conc.titulo as titulo,conc.post_date as post_date,conc.validar as validar from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='6' order by $ord $ord2 ");	
	$total_paginas = ceil($total_registros / $registros); 
	
	?>
	<h1>webquest</h1><br>
  	<a href="ingweb.php" class="btn_submit">Agregar registro</a><br><br><br>
  
    
    <div id="result"></div>
   <table id="tabla_registro" class="table table-hover" >
   
    <thead>
  <tr bgcolor="#E4E4E4">
 
   <!-- <td width="42" bgcolor="#D6D6D6" height="30"><strong>Código</strong></td>-->
    <th > <a href="list_web.php?ord=titulo">Titulo ▼</a></th>
  
  
   
   
  
 
    <th  ><a href="list_web.php?ord=post_date">Fecha Registro ▼</a></th><th  >Temas</th>
      <th  >Publicar</th>
       <th  >Vista</th>
    <th  >Actualizar</th>
      
    <th >Eliminar</th>
  </tr>
  </thead>
  
    <?
	  $bkI2=1;
	
	while($campo=mysql_fetch_assoc($resultados))
{

 $strColumns2 = 2;

if (($bkI2 % $strColumns2) == 0)
		{
			$a="#F2F2F2";
			
			
		}	
		
		else
		
		{
		$a="#FFFFFF";
			
		}	
		
		$fec= $campo['post_date'];
                preg_match('/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/',$fec,$cam);
                $fec2= $cam[3]."-".$cam[2]."-".$cam[1]; 
				
			$ImgH=$campo['id_concep'];
			$resI = mysql_query("SELECT * FROM tb_himg WHERE id_concep='".$ImgH."'");
	$totReg = mysql_num_rows($resI); 
if($totReg>0)
{
$Home=" <img src='images/h.png' width='13' height='13' border='0' title='Se encuentra en el Home como imagen.'>";
}
else
{
	$Home="<a href='#' onClick=deleteRow('".$campo['id_concep']. "')> <img src='images/elim.jpg' width='13' height='13' border='0' > </a>";
	
	}

echo("<tbody><tr >


<td>".utf8_encode($campo['titulo'])."</td>


<td>$fec2 </td>


<td ><a href=javascript:ventanaSecundaria2('agr_tem2.php?act=".$campo['id_concep']."')><img src='images/subir.jpg' width='30' height='30' border='0' > </a></td>




<td> <a href='#' onClick=validar('".$campo['id_concep']. "','".$campo['validar']. "')><img src='images/".$campo['validar']. ".jpg' width='15' height='15' border='0' ></a> </td>

<td> <a  href=javascript:ventanaSecundaria3('../articuloPrev.php?cod=".$campo['id_concep']."')><img src='images/previa.jpg' width='15' height='15' border='0' ></a> </td>



<td align='center'><a href=javascript:ventanaSecundaria('act_Preg.php?act=".$campo['id_concep']."')> <img src='images/edit2.jpg' width='20' height='20' border='0' > </a></td>

<td align='center'>".$Home. "</td>
</tr></tbody>");


$bkI2 = $bkI2 + 1;	
	
	}
	mysql_free_result($resultados)
	?>
   
</table>
<table  border="0" align="center">
  <tr>
    <td>
    <?
	
	
	if($total_registros) {
		
		echo "<div align='right'>";
		
		if(($pagina- 1) > 0) {
			echo "<a  href='list_web.php?pagina=".($pagina-1)."&ord=$ord'><<</a> ";
		}
		
		for ($i=1; $i<=$total_paginas; $i++){ 
			if ($pagina == $i) 
				echo "<span >".$pagina."</span> "; 
			else
				echo "<a  href='list_web.php?pagina=$i&ord=$ord'>($i)</a> "; 
		}
	  
		if(($pagina + 1)<=$total_paginas) {
			echo " <a  href='list_web.php?pagina=".($pagina+1)."&ord=$ord'>>></a>";
		}
		
		echo "</div>";// siguiente tmbien debe llevar las variab
		
	}
	
	?>
    </td>
  </tr>
</table>












</div>
<?
} 
else

{?>
<div align="center">
	<h3>Usuario no permitido</h3>
	<p>
		<a href="login.php">Inicio</a>
	</p>
</div>
<?
}
?>

 
</body>
</html>